/*
*  Engine.cpp
*  SypXIPhone
*
*  Created by Luv Khemani on 5/14/10.
*  Copyright 2010 Luv Khemani. All rights reserved.
*
*/
#ifdef SYPX_MEMCHECK
#include "mmgr.h"
#endif

#include "Engine.h"
#include "Base.h"
#include "Canvas.h"
#include "CanvasDesktopGL.h"
#include "ResourceManager.h"
#include "RendererGL2.h"

#ifdef SYPX_PLATFORM_WIN32
#include "AudioEngineWindows.h"
#else
#include "AudioEngineOAL.h"
#endif

namespace SypX
{
	String Engine::getFilePath(const SypX::String &filename)
	{
		String file = filename;
		return file;
	}

	Canvas* Engine::createCanvas(UInt width, UInt height)
	{
		if(width && height)//both are not 0
		{
			return new CanvasDesktopGL(width,height);
		}
		else
		{
			return new CanvasDesktopGL();
		}

	}

	//On Desktop we just call init straight away after creating the Canvas/Window
	void Engine::initAndStart(UInt width, UInt height)
	{
		canvas = createCanvas(width, height);
		init(width, height);
		//On Desktop we can handle run loop ourselves
		if(runFunction)
		{
			while(canvas->isOpen())
			{
				runFunction();
			}
		}
	}

	AudioEngine* Engine::createAudioEngine()
	{
		#ifdef SYPX_PLATFORM_WIN32
				return new AudioEngineWindows();
		#else
				return new AudioEngineOAL();
		#endif
	}


	Renderer* Engine::createRenderer()
	{
		return new RendererGL2();
	}

}
